﻿using System;
using System.Net.Mail;
using MammothMicro.SMTPGuard;
using MammothMicro.SMTPGuard.Common;
using MammothMicro.SMTPGuard.Filter;
using MammothMicro.SmtpGuardFilter.Common;

namespace MammothMicro.SmtpGuardFilter.Filter
{
    /// <summary>
    /// Checks if subject is null
    /// </summary>
    public class NullSubjectFilter :IEmailFilter
    {
        #region IEmailFilter Members

        public bool Accept(MailMessage message)
        {
            if (FilterManager.BlockNullSubject && message.Subject == string.Empty)
            {
                var msg = new SerializableMailMessage
                              {
                                  Email = message,
                                  Id = new Guid(),
                                  FilteredBy = Tools.Filters.NullSubjectFilter
                              };
                FilterManager.MailStore.Save(msg);
                return false;
            }
            return true;
        }

        public void Reload()
        {
            throw new NotImplementedException();
        }

        #endregion
    }
}


